﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;

public partial class Search : System.Web.UI.Page
{
    public string Keywords = "C语言";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Keywords = Request.QueryString["queryKey"];
            Title = Keywords + "的搜索结果-" + ConfigurationManager.AppSettings["siteName"];
            try
            {
                if (Request.QueryString["type"] == "title")
                {
                    Repeater1.DataSource = SearchByTitle().Tables[0].DefaultView;
                }
                else if (Request.QueryString["type"] == "content")
                {
                    Repeater1.DataSource = SearchByContent().Tables[0].DefaultView;
                }
                Repeater1.DataBind();
            }
            catch (NullReferenceException ex)
            { }
        }
    }

    protected DataSet SearchByTitle()
    {
        DataSet ds = new DataSet();
        ds = new Cstudy.BLL.Artcles().SearchArtcleTitle(Keywords);
        return ds;
    }

    protected DataSet SearchByContent()
    {
        DataSet ds = new DataSet();
        ds = new Cstudy.BLL.Artcles().SearchArtcleContent(Keywords);
        return ds;
    }
}